/* dateTime_windows.h.c */

#include <stdio.h>
#include <windows.h>

/*
    For BEGINNING COMPUTER PROGRAMMING using HLA, Python, C/C++
    http://developers-heaven.net/forum/index.php/topic,46.0.html

    typedef struct _SYSTEMTIME
    {
        WORD wYear;
        WORD wMonth;
        WORD wDayOfWeek;
        WORD wDay;
        WORD wHour;
        WORD wMinute;
        WORD wSecond;
        WORD wMilliseconds;
    }SYSTEMTIME, *PSYSTEMTIME;
*/

char* weekDayStr[] =
{
    "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday",
    "Friday", "Saturday",
    "1st", "2nd", "3rd", "4th", "5th", "6th", "7th"
};

int main()
{
    SYSTEMTIME st, lt;
    GetSystemTime(&st);
    GetLocalTime(&lt);

    printf( "The system date and time is: %04d-%02d-%02d %02d:%02d:%02d\n",
            lt.wYear, lt.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond );
            
    printf( "\nThe local  date and time is: %04d-%02d-%02d %02d:%02d:%02d",
            lt.wYear, lt.wMonth, st.wDay, lt.wHour, lt.wMinute, st.wSecond );
    printf( " the %s weekday, %s.\n",
            weekDayStr[lt.wDayOfWeek+7], weekDayStr[lt.wDayOfWeek] );

    fputs( "\nPress 'Enter' to continue ... ", stdout );
    getchar();
    return 0;
}
